/*
ID: icerupt1
PROG: preface
LANG: C++11
*/
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>

std::ifstream fin {"preface.in" };
std::ofstream fout{"preface.out"};

int n;

//x < 3500
std::string roman_number(int x)
{
	if (x == 0) return "";

	if (x >= 3000) return ("MMM" + roman_number(x - 3000));
	if (x >= 2000) return ( "MM" + roman_number(x - 2000));
	if (x >= 1000) return (  "M" + roman_number(x - 1000));

	if (x >= 900) return ("CM" + roman_number(x - 900));
	if (x >= 500) return ("D" + roman_number(x - 500));
	if (x >= 400) return ("CD" + roman_number(x - 400));
	if (x >= 300) return ("CCC" + roman_number(x - 300));
	if (x >= 200) return ( "CC" + roman_number(x - 200));
	if (x >= 100) return (  "C" + roman_number(x - 100));

	if (x >= 90) return ("XC" + roman_number(x - 90));
	if (x >= 50) return ("L" + roman_number(x - 50));
	if (x >= 40) return ("XL" + roman_number(x - 40));
	if (x >= 30) return ("XXX" + roman_number(x - 30));
	if (x >= 20) return ( "XX" + roman_number(x - 20));
	if (x >= 10) return (  "X" + roman_number(x - 10));

	if (x == 9) return ("IX");
	if (x >= 5) return ("V" + roman_number(x - 5));
	if (x == 4) return "IV";
	if (x >= 3) return ("III" + roman_number(x - 3));
	if (x >= 2) return ( "II" + roman_number(x - 2));
	return ("I" + roman_number(x - 1));
}

int main()
{
	std::vector<char> roman_characater{'I', 'V', 'X', 'L', 'C', 'D', 'M'};
	std::unordered_map<char, int> count;
	fin >> n;
	for (int i = 1; i <= n; i++) {
		for (auto ch : roman_number(i)) count[ch]++;
	}
	for (auto ch : roman_characater)
		if (count[ch] != 0) {
			std::cout << ch << ' ' << count[ch] << '\n';
			fout << ch << ' ' << count[ch] << '\n';
		}
}
